package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Setter @Getter
@JsonIgnoreProperties("handler")
public class ProductCatalog extends BaseDomain{
    public static final Integer STATE_NOMAL = 0; //上线
    public static final Integer STATE_DISABLE = 1; //下架

    /**
     * 商品分类名称
     */
    private String name;

    /**
     * 分类状态
     */
    private Integer state = STATE_NOMAL;

    /**
     * 背景图片
     */
    private String coverUrl;


    /**
     * 积分商品
     */
    private List<Product> list;


    public String getStateName(){
        String stateName = "上线";
        if (STATE_DISABLE.equals(state)){
            stateName = "下架";
        }
        return stateName;
    }

    public String getJson(){
        Map<String, Object> map = new HashMap<>();
        map.put("id", getId());
        map.put("name",name);
        map.put("coverUrl", coverUrl);
        map.put("state", state);
        return JSON.toJSONString(map);
    }

}